package com.example.flatlafdemo.components.scrollPane;

import javax.swing.*;
import java.awt.*;

public class ScrollPaneDemo extends JScrollPane {

    public ScrollPaneDemo() {
        initPane();
    }

    private void initPane() {
        ImageIcon icon = new ImageIcon("icons/scrollpane/crayons.jpg");
        JPanel p = new JPanel(new BorderLayout());
        p.add(new JLabel(icon), BorderLayout.CENTER);
        getViewport().add(p);

        ImageIcon colIcon = new ImageIcon("icons/scrollpane/colheader.jpg");
        JLabel colHeader = new JLabel(colIcon);
        setColumnHeaderView(colHeader);

        ImageIcon rowIcon = new ImageIcon("icons/scrollpane/rowheader.jpg");
        JLabel rowHeader = new JLabel(rowIcon);
        setRowHeaderView(rowHeader);

        ImageIcon upperLeftIcon = new ImageIcon("icons/scrollpane/upperleft.jpg");
        JLabel cornerUL = new JLabel(upperLeftIcon);
        setCorner(UPPER_LEFT_CORNER, cornerUL);

        ImageIcon upperRightIcon = new ImageIcon("icons/scrollpane/upperright.jpg");
        JLabel cornerUR = new JLabel(upperRightIcon);
        setCorner(UPPER_RIGHT_CORNER, cornerUR);

        ImageIcon lowerLeftIcon = new ImageIcon("icons/scrollpane/lowerleft.jpg");
        JLabel cornerLL = new JLabel(lowerLeftIcon);
        setCorner(LOWER_LEFT_CORNER, cornerLL);

        JScrollBar vsb = getVerticalScrollBar();
        JScrollBar hsb = getHorizontalScrollBar();

        vsb.setValue(icon.getIconHeight());
        hsb.setValue(icon.getIconWidth() / 10);
    }
}
